﻿using System;
using System.Xml.Linq;

namespace CodeCounsel.SharePoint.RibbonDesigner.Model
{
    [XName("ContextualGroup", Namespaces.CommandUIText)]
    public class ContextualGroup
        : CollectionDomainElement<Tab>
    {
        public ContextualGroup(XElement dataModel, DomainModelSource source)
            : base(dataModel, source)
        {
        }

        public ContextualGroup()
        {
        }

        protected override void RaiseDomainElementRemoved(DomainElement item)
        {
            if (item is Tab)
            {
                OnTabRemoved(new DomainElementEventArgs<Tab>((Tab)item));
            }
        }

        protected virtual void OnTabRemoved(DomainElementEventArgs<Tab> e)
        {
            if (TabRemoved != null)
            {
                TabRemoved(this, e);
            }
        }

        public event EventHandler<DomainElementEventArgs<Tab>> TabRemoved;
    }
}
